/*
* @Description: index
* @Verson: v1.0
* @Author: xvyy
* @Date: 2024-11-28 16:23
*/
import {createRouter, createWebHistory} from 'vue-router';
import Home from '../views/Home.vue';
import Hello from '../views/Hello.vue';
import User from "../views/user/User.vue";
import UserProfile from "../views/user/UserProfile.vue";
import UserPosts from "../views/user/UserPosts.vue";

// 1. 定义路由表
const routes = [
    {path: '/', component: Home},
    {path: '/hello', component: Hello},
    {path: '/haha/: id', component: () => import('../views/Haha.vue')} ,
    {
        path: '/user/:id',
        component: User,
        name: 'user',
        children: [
            {path: 'profile', name: 'Profile',  component: UserProfile},
            {path: 'posts' , name: 'Posts', component: UserPosts}
        ]
    }
];
// 2. 创建路由器
const router = createRouter({
    history: createWebHistory(),
    // routes: routes ,
    routes ,
})

// 3. 导出路由器
export default router;

// 4. vue实例使用路由器
